<?php
ob_start();
include_once 'Model/Player.php';

session_start();

if (!$_SESSION['player']) {       
     	$player = Player::newWithRandomTeam();
        
        $_SESSION['player'] = $player;

}else {
        $player = $_SESSION['player'];

}
?>
<!DOCTYPE html>
<html>
	<head>
		<link rel="stylesheet" type="text/css" media="all" href="Css/style.css" />
		<script type="text/javascript" src="Js/jquery-1.7.1.min.js"></script>
		<script type="text/javascript" src="Js/config.js"></script> 
		<script type="text/javascript" src="Js/helpers.js"></script> 
		<script type="text/javascript" src="Js/main.js"></script> 
		<script type="text/javascript" src="Js/ajax-controller.js"></script> 
		<script type="text/javascript">
			loadTeam(<?php echo $player->team()->id() ?>);
		</script>

	</head>
	<body>
		<canvas id="main"></canvas>
		
		<div id="playerInfos">
<?php 
			$teams = OPDatabase::allTeams();
?>

			<TABLE id="tableau_scores">
				<TR>
<?php 
					foreach ($teams as $team) {
						echo '<TH>';
						echo $team->color();
						echo '</TH>';
						
					}
?>
				</TR>
				<TR>
<?php 
					foreach ($teams as $team) {
						echo '<TD>';
						echo number_format($team->occupation(), 0) . "%";
						echo '</TD>';
						
					}
?>
				</TR>
			</TABLE> 
		</div>
	</body>	
</html>
